<html ng-app="diandanbao" class="ng-scope">
<head>
    <style type="text/css">@charset "UTF-8";
    [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak, .ng-hide:not(.ng-hide-animate) {
        display: none !important;
    }

    ng\:form {
        display: block;
    }</style>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta content="telephone=no" name="format-detection">
    <title>我要排号</title>
    <link data-turbolinks-track="true" href="{RES}/mobile/{php echo $this->cur_tpl}/assets/diandanbao/weixin.css" media="all" rel="stylesheet">
    <script src="{RES}/mobile/{php echo $this->cur_tpl}/assets/diandanbao/jquery-1.11.3.min.js"></script>
    <style type="text/css">@media screen {
        .smnoscreen {
            display: none
        }
    }

    @media print {
        .smnoprint {
            display: none
        }
    }</style>
</head>
<body>

<!-- ngView:  -->
<div ng-view="" style="height: 100%;" class="ng-scope">
    <div id="queue-index-page" class="ng-scope">
        <div class="ddb-nav-header">
            <div class="nav-left-item" onclick="location.href='{php echo $this->createMobileUrl('detail', array('id' => $storeid), true)}';"><i class="fa fa-angle-left"></i></div>
            <div class="header-title ng-binding">我要排号</div>
            <div class="nav-right-item">
                {if $config['queuemode']!=2 || $queueid!=0}
                <div class="operation-button" onclick="postmain();">保存</div>
                {/if}
            </div>
        </div>
        <div class="main-view">
            <div class="space-12"></div>
            <div class="section" id="new-guest-queue-section">
                {if $config['queuemode']!=2 || $queueid!=0}
                <div class="list-item ddb-form-control ng-scope">
                    <div class="ddb-form-label">客人数量</div>
                    <input type="number" class="ddb-form-input ng-pristine ng-untouched ng-valid" id="usercount" name="usercount" placeholder="填写人数">
                </div>
                <div class="list-item ddb-form-control ng-scope">
                    <div class="ddb-form-label">手机号</div>
                    <input type="number" class="ddb-form-input ng-pristine ng-untouched ng-valid" id="usermobile" name="usermobile" placeholder="填写手机号">
                </div>
                {elseif $config['queuemode']==2}
                <div class="queue-blocks section ng-scope">
                    <div class="list-item">选择队列</div>
                    <div class="list-item">
                        {php $index = 0;}
                        {loop $list $item}
                        {php $color = $index%3;}
                        {if $color==0}
                        {php $lablecolor = 'label-green';}
                        {elseif $color==1}
                        {php $lablecolor = 'label-red';}
                        {elseif $color==2}
                        {php $lablecolor = 'label-orange';}
                        {/if}
                        <div class="choose-queue-setting-label ng-scope" onclick="location.href='{php echo $this->createMobileUrl('queueform', array('storeid' => $storeid, 'queueid' => $item['id']), true)}';">
                            <div class="text ng-binding {$lablecolor}">
                                {$item['title']}
                            </div>
                        </div>
                        {php $index++;}
                        {/loop}
                        <div class="space"></div>
                    </div>
                </div>
                {/if}
                <div class="space"></div>
            </div>
        </div>
    </div>
</div>
<script>
    function postmain() {
        var url = "{php echo $this->createMobileUrl('setqueue', array('storeid' => $storeid, 'queueid' => $queueid), true)}";
        var usermobile = $("#usermobile").val();
        var usercount = $("#usercount").val();
        if (usermobile == "") {
            alert('请输入手机号码!');
            return false;
        }
        if (usercount == "") {
            alert('请输入人数!');
            return false;
        }

        $.ajax({
            url: url, type: "post", dataType: "json", timeout: "10000",
            data: {
                "usermobile": usermobile,
                "usercount": usercount
            },
            success: function (data) {
                if (data.status == 1) {
                    location.href='{php echo $this->createMobileUrl('queue', array('storeid' => $storeid), true)}';
                } else {
                    alert(data.msg);
                }
            },error: function () {
                alert("网络不稳定，请重新尝试!");
            }
        });
    }
</script>
</body>
</html>